Backend table db structure#1751
Conversation
📝 WalkthroughWalkthroughThe connection diagram retrieval endpoint's authorization guard is changed from ChangesAuthorization Guard Update
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
There was a problem hiding this comment.
Pull request overview
This PR adjusts backend authorization for the connection database-structure diagram endpoint in the connection controller. In the broader codebase, this endpoint serves a read-only schema visualization for an existing connection.
Changes:
- Replaced the guard on
GET /connection/diagram/:connectionId. - The endpoint now requires
ConnectionEditGuardinstead ofConnectionReadGuard.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| type: ConnectionDiagramResponseDTO, | ||
| }) | ||
| @UseGuards(ConnectionReadGuard) | ||
| @UseGuards(ConnectionEditGuard) |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
backend/src/entities/connection/connection.controller.ts (1)
724-745:⚠️ Potential issue | 🟠 Major | ⚡ Quick winConfirm that restricting diagram retrieval to edit-level users is intentional.
GET /connection/diagram/:connectionIdis a pure read operation (no mutations,InTransactionEnum.OFF), yet it is now guarded byConnectionEditGuard(CedarAction.ConnectionEdit). Every other read-onlyGETin this controller (e.g.,/connection/users/:connectionId) usesConnectionReadGuard.Concretely, any user who holds
ConnectionReadbut notConnectionEditwill receive a403 Forbiddenwhen trying to fetch the Mermaid diagram — a capability they previously had.If the intent is to restrict schema visibility to editors/admins only (reasonable for sensitive schema data), please add a short comment documenting the rationale so future reviewers don't treat it as a bug. If it's unintentional, revert to
ConnectionReadGuard:↩️ Revert to read-level guard
- `@UseGuards`(ConnectionEditGuard) + `@UseGuards`(ConnectionReadGuard) `@Get`('/connection/diagram/:connectionId')🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@backend/src/entities/connection/connection.controller.ts` around lines 724 - 745, The getConnectionDiagram handler (getConnectionDiagram) is currently protected by ConnectionEditGuard (CedarAction.ConnectionEdit) which blocks users with only ConnectionRead permission; either document this intentional restriction by adding an inline comment above the `@UseGuards`(ConnectionEditGuard) explaining why diagram access requires edit-level rights, or if that was unintentional change, replace ConnectionEditGuard with ConnectionReadGuard so read-only users can access the diagram; update the annotation/comment adjacent to getConnectionDiagram to reflect the chosen policy.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@backend/src/entities/connection/connection.controller.ts`:
- Around line 724-745: The getConnectionDiagram handler (getConnectionDiagram)
is currently protected by ConnectionEditGuard (CedarAction.ConnectionEdit) which
blocks users with only ConnectionRead permission; either document this
intentional restriction by adding an inline comment above the
`@UseGuards`(ConnectionEditGuard) explaining why diagram access requires
edit-level rights, or if that was unintentional change, replace
ConnectionEditGuard with ConnectionReadGuard so read-only users can access the
diagram; update the annotation/comment adjacent to getConnectionDiagram to
reflect the chosen policy.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: fb67201d-f1d9-44de-af02-cf4f110ec8de
📒 Files selected for processing (1)
backend/src/entities/connection/connection.controller.ts
Summary by CodeRabbit